<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue基础模板</title>
    <script src="https://cdn.bootcss.com/vue/2.5.13/vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" v-focus v-color="mycolor">
    </div>
</body>

</html>
<script>
    Vue.directive("color", {
        inserted: function(el, binding) {
            el.style.color = binding.value;
        }
    });

    Vue.directive("focus", {
        inserted: function(el, binding) {
            el.focus();

        }
    });

    var app = new Vue({
        el: "#app",
        data: {
            number: 1,
            mycolor: "red",
        }
    })
</script>